#include <stdio.h>
#include <dirent.h>

int main(int argc, char *argv[])
{
    DIR *dp;
    struct dirent *dirp;
    if (argc!= 2) {
        printf("a single argument (the directory name) is required");
        return 0;
    }
    if ((dp = opendir(argv[1])) == NULL) {
        printf("can't open %s", argv[1]);
        return 0;
    }
    while ((dirp = readdir(dp))!= NULL) {
        printf("%s\n", dirp->d_name);
    }
    closedir(dp);
    return 0;
}
